<?php
/**
 * @author wangxi
 * @desc user system bootstrap file
 * Date 15-1-26
 * @modify 2015-12-1
 */
define('USER_SYSTEM_START', microtime(true));

//use composer autoload
require __DIR__ . '/../vendor/autoload.php';

define('P_ROOT', str_replace('\\', '/', dirname(__DIR__)) . DIRECTORY_SEPARATOR);
define('P_APP', P_ROOT.'app/');
define('P_SRC', P_ROOT . 'src/');
define('P_INC', P_SRC . 'inc/');

//debug switch
define('DEBUG_ON', true);
if (DEBUG_ON) {
    error_reporting(E_ALL & ~E_NOTICE);
    ini_set('display_errors', 1);
    ini_set('log_errors', 1);
    ini_set('error_log', P_APP . 'log/dev.log');
    ini_set('html_errors', 1);
}
else {
    error_reporting(0);
    ini_set('log_errors', 1);
    ini_set('error_log', P_APP . 'log/prod.log');
    ini_set('display_errors', 0);
    ini_set('html_errors', 0);
}

//setup include_path
define('PATH_SEP', PHP_OS == 'WINNT' ? ';' : ':');
ini_set('include_path', implode(PATH_SEP, array('.', P_SRC, P_INC)));

//fix timezone
date_default_timezone_set('Asia/Shanghai');
if(extension_loaded('mb_string')){
    mb_internal_encoding('UTF-8');
}

//session switch
//TODO:in vagrant session.save_path=./tmp will raise error
//so change tmp path to /var/tmp
//ini_set('session.save_path', '/var/tmp');
//if (session_id() == '') {
//    session_start();
//}

//import common func
require P_INC . 'common.php';

//import pre-load libraries or helpers
import(array(
    'util',
    'security'

), 'helper');

